/**
 *
 */
package cn.dw.mm.service.impl;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.dw.mm.domain.Role;
import cn.dw.mm.domain.User;
import cn.dw.mm.mapper.RoleMapper;
import cn.dw.mm.mapper.UserMapper;
import cn.dw.mm.service.UserService;

/**
 * @author aubrey
 * @date  上午10:57:17
 * 
 */
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper userMapper ;
	

	@Override
	public int deleteByPrimaryKey(String id) {
		
		return userMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(User record) {
		return userMapper.insert(record);
	}

	@Override
	public int insertSelective(User record) {
		return userMapper.insertSelective(record);
	}

	@Override
	public User selectByPrimaryKey(String id) {
		return userMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(User record) {
		return userMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(User record) {
		return userMapper.updateByPrimaryKey(record);
	}

	@Override
	public List<User> selectAll(User user) {
		return userMapper.setAll(user);
	}

	@Override
	public String login(User user) {
		return userMapper.login(user);
	}

	@Override
	public HSSFWorkbook excel(User user) {
		  //第一步创建workbook  
	        HSSFWorkbook wb = new HSSFWorkbook();  
	          
	        //第二步创建sheet  
	        HSSFSheet sheet = wb.createSheet("测试");  
	          
	        //第三步创建行row:添加表头0行  
	        HSSFRow row = sheet.createRow(0);  
	        HSSFCellStyle  style = wb.createCellStyle();      
	        //style.setAlignment(HSSFCellStyle.ALIGN_CENTER);  //居中  
	          
	          
	        //第四步创建单元格  
	        HSSFCell cell = row.createCell(0); //第一个单元格  
	        cell.setCellValue("姓名");  
	        cell.setCellStyle(style);  
	        
	        
	        
	        cell = row.createCell(1);         //第二个单元格     
	        cell.setCellValue("年龄");  
	        cell.setCellStyle(style);  
	          
	       
	        //第五步插入数据  
	       
	        for (int i = 0; i < 5; i++) {  
	            //创建行  
	            row = sheet.createRow(i+1);  
	            //创建单元格并且添加数据  
	            row.createCell(0).setCellValue("aa"+i);  
	            row.createCell(1).setCellValue(i);  
	            
	        }  
	      return wb; 
	        //第六步将生成excel文件保存到指定路径下  
	       /* try {  
	            FileOutputStream fout = new FileOutputStream("C:\\Users\\IBM_ADMIN\\Desktop\\promotion\\a.xls");  
	            wb.write(fout);  
	            fout.close();  
	        } catch (IOException e) {  
	            e.printStackTrace();  
	        }  
	          
	        System.out.println("Excel文件生成成功...");  */
	    }  
		      

}
